<template>
  <div>
    <div v-for="(item, index) in categoryList" :key="index">
      <div class="title">
        {{ item.name }}
      </div>

      <div class="commodity">
        <div
          class="commodity1"
          v-for="val in item.goodsList"
          :key="val.id"
          :data-id="val.id"
          @click="goDetails(val.id)"
        >
          <img class="commodity_img" :src="val.list_pic_url" />
          <div>{{ val.name }}</div>
          <div class="price">{{ Number(val.retail_price).toFixed(2) }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["categoryList"],
  data() {
    return {};
  },
  methods: {
    goDetails(id) {
      this.$router.push(`/details?id=${id}`);
      // console.log();
    },
  },
};
</script>
 
<style lang = "less" scoped>
/* component/jj/jj.wxss */
.title {
  height: 30px;
  margin-top: 20px;
  line-height: 30px;
}
.commodity {
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  padding-bottom: 10px;
  font-size: 14px;
  color: #333333;
}
.commodity .commodity1 {
  width: 50%;
}
.commodity .commodity1 .commodity_img {
  width: 80%;
}
.commodity .price {
  line-height: 30px;
  color: rgb(182, 111, 85);
}

.title {
  background: #fff;
  text-align: center;
  font-size: 20px;
  padding: 15px;

  margin-top: 20px;
}
</style>